<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>


<body>
<form name="flights" id="flights">
<div id="divFlightDetails">
<div id="divFlightDetails1" style="width:800px; height:500; overflow: auto">
<table><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr></table>
<table style="COLOR: #004040; FONT-WEIGHT: bold; FONT-SIZE: x-small; FONT-FAMILY: 'Verdana'; 
vertical-align: top; border-bottom-style:solid; ; border-bottom-color: gray; 
					border-right-style:solid; ; border-right-color: gray; 
					border-left-style:solid; ; border-left-color: gray; border-top-style:solid; ; border-top-color: gray">
	
		<thead style="BACKGROUND-COLOR: #fbfe70; font-size: " >
			<tr>
			<td colspan="11" align="center" ><c:out  value="${param.origin}"></c:out>-<c:out  value="${param.destination}"></c:out>
			</td>
		</tr>
			<tr>
				<td>Check one</td>
				<td>Flight Number</td>
				<td>Airline</td>
				<td >Source</td>
				<td >Intermediate</td>
				<td >Destination</td>
				<td >EAT</td>
				<td >Int EAT</td>
				<td >Int EDT</td>
				<td># Available</td>
				<td>Fare ($)</td>		
				
			</tr>
		</thead>
		<c:if test="${not empty oneWayTripFlights}">
			<c:set var="i" value="1"/>
			<c:forEach items="${oneWayTripFlights}" var="item">
			<c:if test="${i % 2 == 0}">
				<c:set value="BACKGROUND-COLOR: #d6d6d6;" var="style"></c:set>
			</c:if>
			<tr style="${style}">
				<c:set value="" var="style"></c:set>
				<td>
				 <input type="radio"  name="flightId_oneway" value="<c:out value='${item.flightId}'></c:out>"></input> 
				</td>
				<td><c:out value="${item.flightNumber}" /></td>
				<td><c:out value="${item.airlineName}" /></td>
				<td><c:out value="${item.source}"></c:out></td>
				<td><c:out value="${item.intermediate}" /></td>
				<td><c:out value="${item.destination}" /></td>
				<td><c:out value="${item.timeOfFlight}" /></td>
				
				<td><c:out value="${item.intermediateArrivalTime}"></c:out></td>
				<td><c:out value="${item.intermediateDepartureTime}" /></td>
				<td><c:out value="${item.numAvailableSeats}" /></td>
				<td><c:out value="${item.ticketPrice}" /></td>				
				<c:set var="i" value="${i+1}"/>
			</tr>
			</c:forEach>
		</c:if>
		<c:if test="${empty oneWayTripFlights}">
			<tr>
				<td colspan=11 align="center" style="color:Red; font-size: 11px; font-style: italic;">No flights available</td>
			</tr>
		</c:if>
		</table>  
</div>
<table><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr></table>
<c:if  test="${param.tripType == 'round_trip'}">
<div id="divFlightDetails1" style="width:800px; height:500; overflow: auto">
<table style="COLOR: #004040; FONT-WEIGHT: bold; FONT-SIZE: x-small; FONT-FAMILY: 'Verdana'; vertical-align: top; 
border-bottom-style:solid; ; border-bottom-color: gray; border-right-style:solid; ; border-right-color: gray; border-left-style:solid; ;
 border-left-color: gray; border-top-style:solid; ; border-top-color: gray" >
	
		<thead style="BACKGROUND-COLOR: #fbfe70;">
			<tr>
			<td colspan="11" align="center"><c:out  value="${param.destination}"></c:out>-<c:out  value="${param.origin}"></c:out>
			</td>
		</tr>
			<tr>
				<td>Check one</td>
				<td>Flight Number</td>
				<td>Airline</td>
				<td >Source</td>
				<td >Intermediate</td>
				<td >Destination</td>
				<td >EAT</td>
				<td >Int EAT</td>
				<td >Int EDT</td>
				<td># Available</td>
				<td>Fare ($)</td>		
				
			</tr>
		</thead>
		<c:if test="${not empty returnTripFlights}">
			<c:set var="i" value="1"/>
			<c:forEach items="${returnTripFlights}" var="item">
			<c:if test="${i % 2 == 0}">
				<c:set value="BACKGROUND-COLOR: #d6d6d6" var="style"></c:set>
			</c:if>
			<tr style="${style}">
				<c:set value="" var="style"></c:set>				<td>
					<input type="radio"  name="flightId_return" value="<c:out value='${item.flightId}'></c:out>"></input>
				</td>
				<td><c:out value="${item.flightNumber}" /></td>
				<td><c:out value="${item.airlineName}" /></td>
				<td><c:out value="${item.source}"></c:out></td>
				<td><c:out value="${item.intermediate}" /></td>
				<td><c:out value="${item.destination}" /></td>
				<td><c:out value="${item.timeOfFlight}" /></td>
				<td><c:out value="${item.intermediateArrivalTime}"></c:out></td>
				<td><c:out value="${item.intermediateDepartureTime}" /></td>
				<td><c:out value="${item.numAvailableSeats}" /></td>
				<td><c:out value="${item.ticketPrice}" /></td>				
				<c:set var="i" value="${i+1}"/>
			</tr>
			</c:forEach>
		</c:if>
		<c:if test="${empty returnTripFlights}">
			<tr>
				<td colspan=11 align="center" style="color:Red; font-size: 11px; font-style: italic;">No flights available</td>
			</tr>
		</c:if>
		</table>
</div>  
</c:if>
<c:choose>
	<c:when test="${not empty oneWayTripFlights}">
		<input type="button" value="Reserve Now" onclick="bookTickets()" style="FONT-FAMILY: 'Verdana'; FONT-SIZE: x-small; FONT-WEIGHT: bold;"> </input>
	<!-- 	<input type="button" value="Start New Search" onclick="cancel()"> </input>  -->
	</c:when>
	<c:otherwise>
		<c:choose>
			<c:when test="${not empty returnTripFlights}">
				<input type="button" value="Reserve Now" onclick="bookTickets()" style="FONT-WEIGHT: bold; FONT-SIZE: x-small; FONT-FAMILY: 'Verdana';"> </input>
				<!-- 	<input type="button" value="Start New Search" onclick="cancel()"> </input>  -->
			</c:when>
			<c:otherwise>
				
			</c:otherwise>
		</c:choose>
	</c:otherwise>
</c:choose>
</div>

<div style="display:none" id="userTable">
	<table style="COLOR: #004040; FONT-WEIGHT: bold; FONT-SIZE: x-small; FONT-FAMILY: 'Verdana'; 
vertical-align: top; border-bottom-style:solid; ; border-bottom-color: gray; 
					border-right-style:solid; ; border-right-color: gray; 
					border-left-style:solid; ; border-left-color: gray; border-top-style:solid; ; border-top-color: gray;" align="center">

	<thead style="BACKGROUND-COLOR: #fbfe70; " >
	<tr>
		<td colspan=2> You need to be a registered user to book tickets</td>
	</tr>
	</thead>
		<tr>
			<td>Username:</td>
			<td><input name="username" id="username" type="text"></input></td>
		
		</tr>
		<tr>
			<td>Password:</td>
			<td><input name="password" id="password" type="password"></input></td>
		</tr>
		<tr>
			<td colspan=2 align="center"><input type="button" value="Sign in" onclick="authenticateUser()" style="FONT-WEIGHT: bold; FONT-SIZE: x-small; FONT-FAMILY: 'Verdana';"></input></td>
		</tr>
	
	</table>
</div>
<div style="display:none" id="divPassenger">

</div>
<div style="display:none" id="divError">
<table align="center">
<tr>


	<td style="color: red; FONT-WEIGHT: bold; FONT-SIZE: x-small; FONT-FAMILY: 'Verdana';" align="center">You are not registered. Click here to <a href="javascript:register()">register</a>.</td>
</tr>

</table>
</div>
</form>
</body>
</html>
